package com.longjianghuasheng.logistics.business.mine.fragment

import android.os.Bundle
import android.view.View
import coil.load
import com.longjianghuasheng.logistics.BR
import com.longjianghuasheng.logistics.R
import com.longjianghuasheng.logistics.base.BaseMultiStateFragment
import com.longjianghuasheng.logistics.business.mine.viewmodel.EnterpriseInfoViewModel
import com.longjianghuasheng.logistics.databinding.FragmentEnterpriseInfoBinding
import com.longjianghuasheng.logistics.ext.observer
import com.longjianghuasheng.logistics.ext.selectPicture
import java.lang.Deprecated

@Deprecated
class EnterpriseInfoFragment :
    BaseMultiStateFragment<EnterpriseInfoViewModel, FragmentEnterpriseInfoBinding>() {
    private val cardFrontListener = { _: View ->
        selectPicture {

            mViewModel.card_front = it.realPath

            mDatabind.run {
                ivCardFront.load(it.path)
            }


        }

    }


    override fun initViewModelId(): Int = BR.enterpriseInfoViewModel

    override fun layoutId(): Int = R.layout.fragment_enterprise_info

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        mDatabind.run {


            ivClick.setOnClickListener(cardFrontListener)
            ivCardFront.setOnClickListener(cardFrontListener)
            tvBusinessLicense.setOnClickListener(cardFrontListener)


            btGetCode.setOnClickListener {
                mViewModel.tel = stvPhone.centerEditValue
                mViewModel.onGetCode()

            }
            btnCommit.setOnClickListener {


                mViewModel.run {
                    real_name = stvName.centerEditValue
                    address = stvAddress.centerEditValue
                    contact = stvContacts.centerEditValue
                    tel = stvPhone.centerEditValue
                    code = stvCode.centerEditValue

                    company_info()
                }
            }

        }
    }

    override fun createObserver() {
        super.createObserver()
        mViewModel.notify.observer(this) {
            navigateUp()
        }
    }

    override fun initData() {
        super.initData()
    }

    override fun lazyLoadData() {
        super.lazyLoadData()
    }

}